import role from '@/api/role.js';

const state = {
    role_list: undefined,
    is_create_dialog_show: false,
    is_create: false
}

const getters = {
    role_list: state => state.role_list,
    is_create_dialog_show: state => state.is_create_dialog_show,
    is_create: state => state.is_create
}

const actions = {
    async getRoleList({
        commit
    }, params) {
        if (params) {
          params = Object.assign({}, params);
        }
        await role.getNewRoleList(params).then(res => {
            commit('CHANGE_ROLE_LIST', res)
        })
        params = null;
    }
}

const mutations = {
    CHANGE_ROLE_LIST(state, data) {
        state.role_list = data
    },
    CHANGE_IS_CREATE(state, data) {
        state.is_create = data;
    },
    CHANGE_IS_CREATE_DIALOG_SHOW (state, data) {
        state.is_create_dialog_show = data;
    }
    
}

export default {
    namespaced: true,
    state,
    getters,
    actions,
    mutations
}
